<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>换肤效果</title>
    <style>
        img {
            width: 100px;
            height: 100px;
        }

        div {
            width: 420px;
            background-color: pink;
            margin: 0px auto;
        }
    </style>
</head>

<body>
    <div>
        <img src="images/汽车1.jpg" alt="" />
        <img src="images/汽车2.jpg" alt="" />
        <img src="images/汽车3.jpg" alt="" />
        <img src="images/汽车4.jpg" alt="" />
    </div>
    <script>
        var imgs = document.querySelectorAll("img");
      
        //循环事件
        for (var i = 0; i < imgs.length; i++) {
            imgs[i].onclick = function () {
                document.body.style.backgroundImage='url('+this.src+')';  
            }
        }
    </script>
</body>

</html>